#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=1000010;
const int inf=0x7fffffff;
int T;
int n,m,L,V;
int p[N];
struct kkk{
    int d,v,a;
};
kkk c[N];
float vl[N];
int ans_n;
int powe[30];
void sol_1(){
    //sol_2();
}
void sol_2(){
    //cout<<"2222"<<endl;
    ans_n=0;
    for(int i=1;i<=n;i++){
        if(c[i].d>p[m])continue;
        vl[i]=c[i].v*c[i].v+2*c[i].a*(p[m]-c[i].d);
        if(vl[i]>V*V) ans_n++;
    }
    cout<<ans_n<<" "<<m-1<<endl;
}
void sol_3(){
    ;
}
void sol_4(){
    //cout<<"4444"<<endl;
    vector<int> check[30];
    int b[30];
    bool T[30];
    memset(T,0,sizeof T);
    int ans_n=0;
    int mi=inf;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            //car c[i] check p[j]
            if(p[j]<c[i].d)continue;
            int v=c[i].v*c[i].v+2*c[i].a*(p[j]-c[i].d);
            if(v>V*V){
                check[j].push_back(i);
                //if(i==5) cout<<"SHABI"<<j<<" "<<v<<endl;
                T[i]=1;
            }
        }
    }
    /*
    for(int i=1;i<=n;i++){
        if(T[i]){
            cout<<i<<" ";
        }
    }
    cout<<endl;
    for(int i=1;i<=m;i++){
        cout<<0<<" ";
        for(int j=0;j<check[i].size();j++)
            cout<<check[i][j]<<" ";
        cout<<endl;
    }*/
    for(int i=1;i<=n;i++) if(T[i]) ans_n++;
    for(int k=0;k<powe[m];k++){
        int op=k;
        for(int i=1;i<=m;i++){
            b[i]=op%2;
            op=op>>1;
        }
        /*
        for(int i=1;i<=m;i++){
            cout<<b[i];
        }
        cout<<endl;*/
        bool ton[30];
        memset(ton,0,sizeof ton);
        int ans=0;
        for(int i=1;i<=m;i++){
            if(b[i]==0)continue;
            ans++;
            for(int j=0;j<check[i].size();j++){
                ton[check[i][j]]=1;
            }
        }
        int voi=0;
        for(int i=1;i<=n;i++){
            if(ton[i]==1) voi++;
        }
        if(voi==ans_n){
            mi=min(mi,ans);
           /*
            for(int i=1;i<=m;i++){
                cout<<b[i];
            }
            cout<<endl;*/
        }
    }
    cout<<ans_n<<" "<<m-mi<<endl;
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    powe[0]=1;
    for(int i=1;i<=25;i++){
        powe[i]=powe[i-1]*2;
    }
    cin>>T;
    while(T--){
        cin>>n>>m>>L>>V;
        //cout<<"***"<<n<<" "<<m<<" "<<endl;
        bool ex_1=true,ex_2=true,ex_3=true;
        for(int i=1;i<=n;i++){
            cin>>c[i].d>>c[i].v>>c[i].a;
            //cout<<"***"<<i<<" "<<c[i].d<<endl;
            if(c[i].a<0) ex_1=false,ex_2=false;
            if(c[i].a==0) ex_2=false,ex_3=false;
            if(c[i].a>0) ex_1=false,ex_3=false;
        }
        for(int i=1;i<=m;i++)cin>>p[i];
        if(n<=20&&m<=20){sol_4();continue;}
        if(ex_1) sol_2();
        if(ex_2) sol_2();
        if(ex_3) sol_3();

    }
    return 0;
}
/*
1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15
*/
